(() => {
    const btn = document.createElement("button");
    btn.style.position = "fixed";
    btn.style.left = "100px";
    btn.style.bottom = "100px";
    btn.style.zIndex = "10000";
    document.body.appendChild(btn);
    btn.innerText = "启动"
    const input = document.createElement("input");
    input.style.position = "fixed";
    input.style.left = "100px";
    input.style.bottom = "70px";
    input.style.zIndex = "10000"
    input.value = "5"
    document.body.appendChild(input);
    const sleep = (ms) => new Promise((resolve) => setTimeout(resolve), ms);
    let flag = false;
    let time;
    const start = async () => {
        btn.innerText = "关闭"
        const arr = Array.from(document.getElementsByClassName("package-action")).filter(e => e.innerText == "检查");
        let speed = parseInt(input.value);
        if (isNaN(speed) || speed < 1) speed = 5;
        let i = 0;
        time = setInterval(async () => {
            const item = arr[i];
            if (!item) return close();
            i++;
            item.click();
            await sleep(1000);
            window.open(Array.from(document.getElementsByClassName("ant-btn css-17sses9 ant-btn-primary")).find(e => e.innerText == "打 开").href, "_blank")
        }, speed * 1000 + 1000);
    }
    const close = () => {
        clearInterval(time);
        btn.innerText = "启动"
    }

    btn.onclick = async () => {
        flag = !flag;
        if (flag) start();
        else close()
    }
})()